(function(vc){
    vc.extends({
        propTypes: {
           emitChooseShopSetting:vc.propTypes.string,
           emitLoadData:vc.propTypes.string
        },
        data:{
            chooseShopSettingInfo:{
                shopSettings:[],
                _currentShopSettingName:'',
            }
        },
        _initMethod:function(){
        },
        _initEvent:function(){
            vc.on('chooseShopSetting','openChooseShopSettingModel',function(_param){
                $('#chooseShopSettingModel').modal('show');
                $that._refreshChooseShopSettingInfo();
                $that._loadAllShopSettingInfo(1,10,'');
            });
        },
        methods:{
            _loadAllShopSettingInfo:function(_page,_row,_name){
                var param = {
                    params:{
                        page:_page,
                        row:_row,
                        caId:vc.getCurrentCommunity().caId,
                        name:_name
                    }
                };

                //发送get请求
               vc.http.apiGet('/shopSetting/queryShopSetting',
                             param,
                             function(json){
                                var _shopSettingInfo = JSON.parse(json);
                                $that.chooseShopSettingInfo.shopSettings = _shopSettingInfo.shopSettings;
                             },function(){
                                console.log('请求失败处理');
                             }
                           );
            },
            chooseShopSetting:function(_shopSetting){
                if(_shopSetting.hasOwnProperty('name')){
                     _shopSetting.shopSettingName = _shopSetting.name;
                }
                vc.emit($props.emitChooseShopSetting,'chooseShopSetting',_shopSetting);
                vc.emit($props.emitLoadData,'listShopSettingData',{
                    shopSettingId:_shopSetting.shopSettingId
                });
                $('#chooseShopSettingModel').modal('hide');
            },
            queryShopSettings:function(){
                $that._loadAllShopSettingInfo(1,10,$that.chooseShopSettingInfo._currentShopSettingName);
            },
            _refreshChooseShopSettingInfo:function(){
                $that.chooseShopSettingInfo._currentShopSettingName = "";
            }
        }

    });
})(window.vc);
